(function () {
function blockQeTextInstant() {
const styleId = 'qetext-kill-style';
if (!document.getElementById(styleId)) {
const style = document.createElement('style');
style.id = styleId;
style.innerHTML = `
#qetext{
display:none !important;
visibility:hidden !important;
opacity:0 !important;
pointer-events:none !important;
position:absolute !important;
left:-9999px !important;
top:-9999px !important;
z-index:-9999 !important;
}
.audio-btn-row button {
transition: opacity 0.2s ease;
}
/* State: Stopped - Only Play allowed */
.audio-btn-row.st-stopped #pause,
.audio-btn-row.st-stopped #stop,
.audio-btn-row.st-stopped #resume,
/* State: Playing - Only Pause and Stop allowed */
.audio-btn-row.st-playing #play,
.audio-btn-row.st-playing #resume,
/* State: Paused - Only Resume allowed */
.audio-btn-row.st-paused #play,
.audio-btn-row.st-paused #pause,
.audio-btn-row.st-paused #stop {
opacity: 0.3 !important;
filter: grayscale(1);
cursor: not-allowed !important;
pointer-events: none !important;
}
`;
document.head.appendChild(style);
}
if (!window.qeObserver) {
window.qeObserver = new MutationObserver(() => {
const qe = document.querySelector('#qetext');
if (qe) {
qe.style.setProperty('display', 'none', 'important');
qe.style.visibility = "hidden";
qe.style.opacity = "0";
}
});
window.qeObserver.observe(document.body, {
childList: true,
subtree: true
});
}
}
function applyFix() {
if (!document.body.classList.contains('template-product')) return;
const container = document.querySelector('.buttons');
const target = document.querySelector('.product-main .product-details .single-product-meta');
if (!container || !target) return;
blockQeTextInstant();
const hide = container.querySelector('.hide_text');
const show = container.querySelector('.showtext');
if (hide) hide.remove();
if (show) show.remove();
if (target.nextElementSibling !== container) {
target.parentNode.insertBefore(container, target.nextSibling);
}
container.style.cssText = `
display:flex !important;
flex-direction:column !important;
align-items:flex-start !important;
gap:8px !important;
margin-top:12px !important;
padding:10px 14px !important;
background:#2e7d32 !important;
border-radius:6px !important;
width:fit-content !important;
`;
if (!container.querySelector('.audio-instruction')) {
const text = document.createElement('div');
text.className = "audio-instruction";
text.textContent = "Please click to listen to the audio of the description.";
text.style.cssText = `
color:#fff;
font-size:14px;
font-weight:500;
`;
container.prepend(text);
}
let btnWrapper = container.querySelector('.audio-btn-row');
if (!btnWrapper) {
btnWrapper = document.createElement('div');
btnWrapper.className = "audio-btn-row st-stopped";
btnWrapper.style.cssText = `
display:flex;
align-items:center;
gap:10px;
`;
container.querySelectorAll('button').forEach(btn => {
btn.style.cssText = `
display:flex;
align-items:center;
justify-content:center;
background:transparent;
border:none;
cursor:pointer;
padding:5px;
color:#fff;
`;
btnWrapper.appendChild(btn);
});
container.appendChild(btnWrapper);
}
container.querySelectorAll('svg').forEach(svg => {
svg.style.width = "16px";
svg.style.height = "16px";
});
const close = container.querySelector('.close_sbutton');
if (close && !close.dataset.done) {
close.onclick = () => container.style.display = "none";
close.dataset.done = "1";
}
// --- Button State Management ---
const play = document.getElementById('play');
const pause = document.getElementById('pause');
const stop = document.getElementById('stop');
const resume = document.getElementById('resume');
if (play && pause && stop && resume && btnWrapper) {
const setPlaying = () => {
btnWrapper.classList.remove('st-stopped', 'st-paused');
btnWrapper.classList.add('st-playing');
};
const setPaused = () => {
btnWrapper.classList.remove('st-stopped', 'st-playing');
btnWrapper.classList.add('st-paused');
};
const setStopped = () => {
btnWrapper.classList.remove('st-playing', 'st-paused');
btnWrapper.classList.add('st-stopped');
};
if (!play.dataset.listenersDone) {
// We change classes synchronously to avoid flicker
play.addEventListener('click', setPlaying);
resume.addEventListener('click', setPlaying);
pause.addEventListener('click', setPaused);
stop.addEventListener('click', setStopped);
// Interval to detect when audio ends naturally
// Original script calls handleEnd() which enables Play.
// We should sync our class when that happens.
setInterval(() => {
if (!play.disabled && btnWrapper.classList.contains('st-playing')) {
setStopped();
}
}, 1000);
play.dataset.listenersDone = "1";
}
}
}
let count = 0;
const interval = setInterval(() => {
applyFix();
if (++count > 40) clearInterval(interval);
}, 250);
const observer = new MutationObserver(() => applyFix());
observer.observe(document.body, {
childList: true,
subtree: true
});
})();
.template-index #start_button,
.template-collection #start_button,
.template-product #start_button,
body.template-index .buttons {
display: none !important;
}
.template-collection .buttons,
.template-product .buttons {
display: none !important;
}